<template>
	<view class="container">
		<view class="changeBox">
			<view class="change-item">
				<view class="name f30 c333">原密码:</view>
				<view class="input-box"><input type="password" class="f30 c333" v-model="origin_password" /></view>
			</view>

			<view class="change-item">
				<view class="name f30 c333">新密码:</view>
				<view class="input-box"><input type="password" class="f30 c333" v-model="password" /></view>
			</view>
			<view class="change-item">
				<view class="name f30 c333">确认密码:</view>
				<view class="input-box"><input type="password" class="f30 c333" v-model="truePossowrd" /></view>
			</view>

			<view class="btn tCenter"><text class="f30 cfff " @click="show">确定</text></view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			arry: {},
			origin_password: '',
			user_id: '',
			password: '',
			truePossowrd: ''
		};
	},
	onLoad(e) {
		this.arry = JSON.parse(e.id);
		this.user_id = this.arry.user_id;
	},
	methods: {
		show() {
			if (this.password == this.truePossowrd) {
				this.$ajax('api/v1.user/password', {
					user_id: this.user_id,
					origin_password: this.origin_password,
					password: this.password
				})
					.then(res => {
						this.$open('../../kitty-BasicLogin/login', 0,1500);
						uni.showToast({
							title:'密码修改成功,请重新登录',
									icon: 'none'
						})
					})
					.catch(res => {
						console.log(Error);
					});
			} else {
				uni.showToast({
					title: '密码不一致',
					icon: 'none'
				});
			}
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #ffffff;
}
.changeBox {
	border-top: 20upx #f7f4f8 solid;
	.change-item {
		position: relative;
		left: 0;
		padding: 30upx 20upx;
		border-bottom: 1upx #eee solid;
		.name {
			position: absolute;
			left: 20upx;
		}
		.input-box {
			input {
				width: 100%;
				text-align: left;
				padding: 0 30upx 0 190upx;
			}
		}
	}
	.btn {
		width: 100%;
		padding: 0 30upx;
		box-sizing: border-box;
		margin-top: 115upx;
		text {
			display: block;
			height: 80upx;
			line-height: 80upx;
			background-color: #249af6;
		}
	}
}
</style>
